package ar.edu.unq.wannaplay.tools;

import org.apache.wicket.spring.injection.annot.SpringBean;

import ar.edu.unq.wannaplay.services.EmployeeService;
import ar.edu.unq.wannaplay.utils.LicenceCalendar;

public class CalendarCreator {
    @SpringBean(name = "employeeServiceBean")
    private EmployeeService employeeService;

    public LicenceCalendar nextCalendar(final LicenceCalendar calendar) {
        int month = calendar.getMonth(), year = calendar.getYear();
        if (month == 12) {
            year++;
            month = 0;
        }
        return this.getEmployeeService().getHolidaysCalendar(month + 1, year);
    }

    public LicenceCalendar previousCalendar(final LicenceCalendar calendar) {
        int month = calendar.getMonth(), year = calendar.getYear();
        if (month == 0) {
            year--;
            month = 13;
        }
        return this.getEmployeeService().getHolidaysCalendar(month - 1, year);
    }

    // setters&getters
    public void setEmployeeService(final EmployeeService employeeService) {
        this.employeeService = employeeService;
    }

    public EmployeeService getEmployeeService() {
        return employeeService;
    }
}
